<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <title>股票实时信息</title>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="stylesheet" href="../static/bootstrap-4.3.1-dist/css/bootstrap.css">
    <link rel="stylesheet" href="../static/css/index.css">
    <link rel="stylesheet" href="../static/css/head.css">
    <script src="../static/js/head.js"></script>
    <style>
        table {
            width: 100%;
            max-width: 100%;
        }

        .table th,
        .table td {
            padding: 0.55rem;
        }
    </style>
</head>

<body>
    <header class="my-header">
        <div class="header-container">
            <div class="logo">
                <h1>基于Python爬虫的股票分析预测系统</h1>
                <p>cyz</p>
            </div>
            <nav class="nav-links">
                <ul>
                    <li><a href="{{ url_for('index') }}">主页</a></li>
                    <li><a href="{{ url_for('history') }}">历史数据</a></li>
                    <li><a href="{{ url_for('main') }}">可视化大屏</a></li>
                </ul>
            </nav>

        </div>
        <div class="user-info">
            <ul>
                {% if session['username'] %}
                <li><a href="#">{{ session['username'] }}</a></li>
                <li><a href="{{ url_for('logout') }}">注销</a></li>
                {% else %}
                <li><a href="{{ url_for('login') }}">登录</a></li>
                <li><a href="{{ url_for('register') }}">注册</a></li>
                {% endif %}
                <li>
                    <div id="current-time"></div>
                </li>
            </ul>
        </div>
    </header>

    <div class="container table-responsive">
        <a href="{{ url_for('index') }}">
            <h2>股票实时信息</h2>
        </a>
    </div>
    <div class="text-center">

        <form class="form-inline" method="GET" action="/">
            <input class="form-control mr-sm-2" type="search" placeholder="股票名称或代码" aria-label="Search" name="query">
            <button class="btn btn-outline-success my-2 my-sm-0 align-self-center" type="submit">查询</button>
        </form>
    </div>

    <table class="table">
        <thead>
            <tr>
                </th>
                <th><a href="?sort=code&order={{ 'desc' if sort == 'code' and order == 'asc' else 'asc' }}">股票代码</a>
                </th>
                <th><a href="?sort=name&order={{ 'desc' if sort == 'name' and order == 'asc' else 'asc' }}">股票名称</a>
                </th>
                <th><a href="?sort=price&order={{ 'desc' if sort == 'price' and order == 'asc' else 'asc' }}">当前价格</a>
                </th>
                <th><a href="?sort=Iad&order={{ 'desc' if sort == 'Iad' and order == 'asc' else 'asc' }}">涨跌幅</a></th>
                <th><a href="?sort=Uadr&order={{ 'desc' if sort == 'Uadr' and order == 'asc' else 'asc' }}">涨跌额</a></th>
                <th><a href="?sort=YTD&order={{ 'desc' if sort == 'YTD' and order == 'asc' else 'asc' }}">年初至今</a></th>
                <th><a
                        href="?sort=Turnover&order={{ 'desc' if sort == 'Turnover' and order == 'asc' else 'asc' }}">成交量</a>
                </th>
                <th><a href="?sort=money&order={{ 'desc' if sort == 'money' and order == 'asc' else 'asc' }}">成交额</a>
                </th>
                <th><a href="?sort=Trate&order={{ 'desc' if sort == 'Trate' and order == 'asc' else 'asc' }}">换手率</a>
                </th>
                <th><a
                        href="?sort=Trate&order={{ 'desc' if sort == 'dividend_yield' and order == 'asc' else 'asc' }}">股息率</a>
                </th>
                <th><a
                        href="?sort=market_value&order={{ 'desc' if sort == 'market_value' and order == 'asc' else 'asc' }}">市值</a>
                </th>
            </tr>
        </thead>
        <tbody>
            {% for stock in stock_data %}
            <tr>
                <td>{{ stock['code'] }}</td>
                <td>{{ stock['name'] }}</td>
                <td>{{ stock['price'] }}</td>
                <td>{{ stock['Iad'] }}</td>
                <td>{{ stock['Uadr'] }}</td>
                <td>{{ stock['YTD'] }}</td>
                <td>{{ stock['Turnover'] }}</td>
                <td>{{ stock['money'] }}</td>
                <td>{{ stock['Trate'] }}</td>
                <td>{{ stock['dividend_yield'] }}</td>
                <td>{{ stock['market_value'] }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    <div class="pagination justify-content-center">
        {{ pagination.links }}
    </div>

</body>
<script>
    document.addEventListener('mousewheel', function (e) {
        e = e || window.event;
        if ((e.wheelDelta && event.ctrlKey) || e.detail) {
            event.preventDefault();
        }
    }, { capture: false, passive: false });
    document.addEventListener('keydown', function (event) {
        if ((event.ctrlKey === true || event.metaKey === true)
            && (event.keyCode === 61 || event.keyCode === 107
                || event.keyCode === 173 || event.keyCode === 109
                || event.keyCode === 187 || event.keyCode === 189)) {
            event.preventDefault();
        }
    }, false);
</script>

</html>